#ifndef __MODUTILS_H__
#define __MODUTILS_H__

#define OGRE_SAFE_DELETE(pValue)	if (pValue)			    \
									{                       \
										OGRE_DELETE pValue; \
										pValue = NULL;		\
									}						
#define ARRAY_SIZE(a)				(sizeof(a) / sizeof(a[0])) 

#define		MOD_CUBE_SIZE		(5.f)
#define		MOD_GRID_LINES		(20)
#define		MOD_GRID_COLUMN		(20)
#define		MOD_PIECE_ACC		(4.f)
#define		MOD_PIECE_ACC_STEP	(1.f)
#define		MOD_EPSILON			(0.001f)

enum eMod_Collision
{
	eFlagNone		=	(1 << 1),
	eFlagWallLeft	=	(1 << 2),
	eFlagWallRight	=	(1 << 3),
	eFlagWallDown	=	(1 << 4),
	eFlagCube		=	(1 << 5),	
	eFlagCubeLeft	=	(1 << 6),	
	eFlagCubeRight	=	(1 << 7),	
	eFlagCubeDown	=	(1 << 8),	
};

struct tRect
{
	tRect()
		:	x1(0.f)
		,	y1(0.f)
		,	x2(0.f)
		,	y2(0.f)
	{
	}

	tRect(float a, float b, float c, float d)
		:	x1(a)
		,	y1(b)
		,	x2(c)
		,	y2(d)
	{
	}

	float x1, y1, x2, y2;
};

#define DECLARE_APPSTATE_CLASS(T)												\
	static void Create(AppStateListener* pParent, const Ogre::String& szName)	\
{																				\
	T* pAppState = new T();														\
	pAppState->m_pParent = pParent;												\
	pParent->ManageAppState(szName, pAppState);									\
}

void MatrixFromAxisAngle(Ogre::Matrix4& mat, const Ogre::Vector3& vNormAxis, float angle); 

#endif //__MODUTILS_H__